home *** CD-ROM | disk | FTP | other *** search
/ Aminet 28 / Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso / Aminet / comm / www / UrbCedWWW.lha / urbcedwww / rexx / GetPicSize.ucwx < prev    next >
Encoding:
Text File  |  1998-09-30  |  3.4 KB  |  147 lines

  1. /**************************************************************************/
  2. /*                            GetPicSize.ucwx                             */
  3. /*                                                                        */
  4. /*                    Copyright ©1998 by Dick Whiting                     */
  5. /*                                                                        */
  6. /*------------------------------------------------------------------------*/
  7. /* Used with UrbCedWWW for getting HEIGHT,WIDTH info of a pic.            */
  8. /* This uses Visage - By Magnus Holmgren, but could be modified for use   */
  9. /* with other users supporting similar commands.                          */   
  10. /* See the UrbCedWWW Readme for a more complete description.              */
  11. /**************************************************************************/
  12. /*
  13. $VER: 1.0 Copyright ©1998 by Dick Whiting
  14. */
  15.  
  16. viewer='UTILS:VISAGE %f INFO'     /* command for getting info             */
  17. ENABLED=0                         /* change to ENABLED=1 to enable script */
  18.  
  19.  
  20. /**************************************************************************/
  21. /*                      Nothing to change below here                      */
  22. /**************************************************************************/
  23. if ~enabled then exit                       /* not enabled...exit         */
  24.  
  25. options results
  26. Address CYGNUSED
  27.  
  28. 'CEDTOFRONT'
  29.  
  30. 'STATUS CURSORLINE'
  31. origline=result+1
  32.  
  33. 'STATUS CURSORCOLUMN'
  34. origcol=result+1
  35.  
  36. 'SEARCH FOR' 'SRC=' 1 0 0 0 1
  37. found=result
  38.  
  39. if ~found then do
  40.    'OKAY1' 'Cannot locate SRC= for picture'
  41.    exit
  42. end
  43.  
  44. 'STATUS CURSORLINE'
  45. startline=result+1
  46.  
  47. 'STATUS CURSORCOLUMN'
  48. startcol=result+6
  49.  
  50. 'LL' startline startcol
  51.  
  52. 'MARK'
  53. on=result
  54. if ~on then 'MARK'
  55.  
  56. 'SEARCH FOR' '"""' 0 0 1 0 1
  57. found=result
  58.  
  59. if ~found then do
  60.    'OKAY1' 'Cannot locate end of name for picture'
  61.    exit
  62. end
  63.  
  64. 'STATUS CURSORLINE'
  65. endline=result+1
  66.  
  67. 'STATUS CURSORCOLUMN'
  68. endcol=result
  69.  
  70. 'COPY'
  71. if ~result then do
  72.    'OKAY1' 'Copy name to clip failed'
  73.    exit
  74. end
  75.  
  76. 'STATUS BLOCKBUFFER'
  77. filename=result
  78.  
  79. 'STATUS RESTNAME'
  80. rest=result
  81. if rest='' then do
  82.    'OKAY1' "You must save the file first"
  83.    exit
  84. end
  85.  
  86. 'STATUS FILENAME'
  87. fullfn=result
  88.  
  89. path=substr(fullfn,1,pos(rest,fullfn)-1)
  90.  
  91. select
  92.    when substr(filename,1,3)='../' then do
  93.       path=substr(path,1,length(path)-1)
  94.       path=substr(path,1,lastpos('/',path))
  95.       filename=path||substr(filename,4)
  96.    end
  97.    otherwise filename=path||filename
  98. end
  99.  
  100. 'STATUS INSERTMODE'
  101. ison=result
  102.  
  103. if ~ison then 'INSERT MODE'
  104.  
  105. found=0
  106.  
  107. do i=1 to words(viewer)
  108.    if word(viewer,i)="%f" then do
  109.       found=1
  110.       leave i
  111.    end
  112. end
  113.  
  114. if found then do
  115.    viewer=subword(viewer,1,i-1)||' "'||filename||'" '||subword(viewer,i+1)
  116.    viewer=viewer||' >T:getpic.txt'
  117.    Address Command viewer
  118.    goodopen=open('IN','T:getpic.txt','R')
  119.    if goodopen then do
  120.       titleline=readln('IN')
  121.       message=readln('IN')
  122.       message=substr(message,4)
  123.       if word(message,1)="Couldn't" then do
  124.          'OKAY1' message
  125.          exit
  126.       end
  127.       type=strip(word(message,1))
  128.       size=strip(word(message,2))
  129.       name=strip(subword(message,4))
  130.       parse var size width'x'height'x'depth
  131.       'LL' origline origcol
  132.       'TEXT' ' WIDTH="'strip(width)'" HEIGHT="'strip(height)'"'
  133.    end
  134.    else do
  135.       'OKAY1' 'Unable to open T:getpic.txt'
  136.       exit
  137.    end
  138.    foo=close('IN')
  139.    Address Command 'DELETE T:getpic.txt QUIET'
  140. end
  141. else do
  142.    'OKAY1' 'Viewer command is invalid'
  143.    exit
  144. end
  145.  
  146. return width height
  147.